import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:myflutterproject/basematerialwidgetsdemo.dart';

final IMAGE_SRC =
    'http://b.hiphotos.baidu.com/image/pic/item/0eb30f2442a7d9337119f7dba74bd11372f001e0.jpg';

class HeroDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Hero'),
        centerTitle: true,
      ),
      body: Row(
        children: <Widget>[
          //手势操作
          GestureDetector(
            child: Hero(
              tag: 'imgPage',
              child: Image.network(IMAGE_SRC, fit: BoxFit.fill, width: 300),
            ),
            onTap: () {
              Navigator.push(
                  context,
                  MaterialPageRoute(
                      builder: (_) => NewPage(), fullscreenDialog: true));
            },
          )
        ],
      ),
    );
  }
}

class NewPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Row(
            children: <Widget>[
              //Expanded常用于Row, Column, Flex的子元素中；在使用Expanded子Widget的时候，能够填充满剩余空间。
              Expanded(
                  child:GestureDetector(
                    child: Hero(
                      tag: 'imgPage',
                      child: Image.network(IMAGE_SRC, fit: BoxFit.fill),
                    ),
                    onTap: (){
                      Navigator.pop(context);
                    },
                  )
              ),
            ],
          ),
          SizedBox(height: 30,),
          TextWidget('选项一'),
          SizedBox(height: 30,),
          TextWidget('选项二'),
          SizedBox(height: 30,),
          TextWidget('选项三'),
          SizedBox(height: 30,),
          TextWidget('选项四'),
        ],
      ),
    );
  }
}
